﻿<UserControl x:Class="AtletIS.UI.Views.DisciplineListTreeView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:behaviors="clr-namespace:AtletIS.UI.Behaviors"
             xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
             
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid>
        <TreeView Grid.Row="0" Grid.RowSpan="3" Grid.Column="1" Margin="5" Background="Transparent" BorderThickness="0" 
                  ItemsSource="{Binding DisciplineList}" >

            
            <i:Interaction.Behaviors>
                <behaviors:BindableTreeViewSelectedItemBehavior SelectedItem="{Binding ActiveDisciplineList, Mode=TwoWay}" />
            </i:Interaction.Behaviors>
            
            <TreeView.ItemTemplate>
                <HierarchicalDataTemplate ItemsSource="{Binding SubDisciplineList}">

                    <!-- Level1 template -->
                    <Border BorderThickness="1" BorderBrush="SteelBlue" Background="White" Margin="2" Padding="2,5" CornerRadius="8" Width="280">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="50px" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="6*"/>
                                <RowDefinition Height="4*"/>
                            </Grid.RowDefinitions>
                            <Image Grid.Row="0" Grid.RowSpan="2" Grid.Column="0" Margin="5" Source="{Binding DisciplineListIcon}" />
                            <TextBlock Grid.Row="0" Grid.Column="1" Margin="0,2" Foreground="SteelBlue" FontSize="14" Text="{Binding Name}" TextWrapping="Wrap"/>
                            <TextBlock Grid.Row="1" Grid.Column="1" Foreground="SteelBlue" FontSize="10" Text="{Binding DisciplineListInfo}"/>
                        </Grid>
                    </Border>

                    <HierarchicalDataTemplate.ItemTemplate>
                        <HierarchicalDataTemplate ItemsSource="{Binding SubDisciplineList}">

                            <!-- Level2 template -->
                            <Border BorderThickness="1" BorderBrush="SteelBlue" Background="White" Opacity="0.8" Margin="2" Padding="15,5" CornerRadius="5" Width="231">
                                <Grid>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="6*"/>
                                        <RowDefinition Height="4*"/>
                                    </Grid.RowDefinitions>
                                    <TextBlock Grid.Row="0" Foreground="SteelBlue" FontSize="13" Text="{Binding Name}" TextWrapping="Wrap"/>
                                    <TextBlock Grid.Row="1" Foreground="SteelBlue" FontSize="10" Text="{Binding DisciplineListInfo}"/>
                                </Grid>
                            </Border>

                            <HierarchicalDataTemplate.ItemTemplate>
                                <DataTemplate>
                                    <!-- Level3 template -->
                                    <Border BorderThickness="1" BorderBrush="SteelBlue" Background="White" Opacity="0.8" Margin="2" Padding="15,10" CornerRadius="5" Width="212">
                                        <TextBlock Grid.Row="0" Foreground="SteelBlue" FontSize="12" Text="{Binding Name}" TextWrapping="Wrap"/>
                                    </Border>
                                </DataTemplate>
                            </HierarchicalDataTemplate.ItemTemplate>

                        </HierarchicalDataTemplate>
                    </HierarchicalDataTemplate.ItemTemplate>

                </HierarchicalDataTemplate>
            </TreeView.ItemTemplate>
        </TreeView>
    </Grid>
</UserControl>
